﻿<%@ Page Language="C#"  AutoEventWireup="true" ValidateRequest="false" CodeBehind="notify_manage_queryedit.aspx.cs" Inherits="Ccit.OA.Notify.notify_manage_queryedit" %>
<%@ Register TagPrefix="ccit" Namespace="Ccit.ServerControls" Assembly="Ccit.ServerControls.ActionForm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
         <title>通知管理-查询条件编辑</title>
        <script language="javascript" src="../script/jquery.js" type="text/javascript"></script> 
        <script language="javascript" src="../script/StringClass_Ext.js" type="text/javascript"></script> 
        <script language="javascript" src="../script/jsonlib.js" type="text/javascript"></script> 
        <script language="javascript" src="../script/jcontrol.js" type="text/javascript"></script> 
        <script language="javascript" src="../script/jwindow.js" type="text/javascript"></script>
        <script language="javascript" src="../script/jbase64.js" type="text/javascript"></script>
        <script type="text/javascript">
               function OpenDept(vHid,vTxt)
                {                   
                    OpenUserMultiSelect(vHid,vTxt,0); 
                } 
                var vtype;
                function OpenQuery(type)
                {
                      vtype = type;
                      var obj = document.getElementById('Query');
                         if(obj){
                          obj.style.display=''; //点击按钮，div层显示 
                          document.getElementById("txtQueryName").focus();
                         }
                }
                function doSave()
                {
                    var MsQuery ={};
                    MsQuery.queryid = document.getElementById("_hidsQueryId").value;
                    MsQuery.typeid = document.getElementById("_hidTypeId").value;
                    MsQuery.queryname = document.getElementById("txtQueryName").value;  
                    var type;
                    var radiotype = document.getElementById("radiotype");
                    if(radiotype.checked==true)
                    {
                        type = 0;
                    }
                    var radioDay = document.getElementById("radioDay");
                    if(radioDay.checked==true)
                    {
                        type = 1;
                    }
                    var radioWeek = document.getElementById("radioWeek");
                    if(radioWeek.checked==true)
                    {
                        type = 2;
                    }
                    var radioMonth = document.getElementById("radioMonth");                      
                    if(radioMonth.checked==true)
                    {
                        type = 3;
                    }
                     var radiorange = document.getElementById("radiorange");
                     if(radiorange.checked==true)
                     {
                        if(document.getElementById("txtrange").value.Trim()!="")
                        {
                            type =4 +"~"+document.getElementById("txtrange").value;
                        }   
                        else
                        {
                            alert("之前的多少天没有填写")
                            return false;
                        }                     
                     }
                     var radioDesignated = document.getElementById("radioDesignated");
                     if(radioDesignated.checked==true)
                     {
                        var begintime = document.getElementById("txtBeginTime").value;
                        var Endtime = document.getElementById("txtEndTime").value;
                        if(begintime.Trim()!=""&&Endtime.Trim()!="")
                        {
                            if(!begintime.IsDate()&&!Endtime.IsDate())
                            {
                                alert("指定范围时间格式不正确!")
                                return false;
                            }
                            else
                            {
                               type =5+"~"+begintime+"~"+Endtime;
                            }
                        }
                        else
                        {
                            alert("尚未填写指定范围时间!")
                            return false;
                        }
                     }
                    var vtitle = document.getElementById("txtTitle").value;
                    var content = document.getElementById("txtContent").value;
                    var userid = document.getElementById("_hidUserId").value;
                    var Level = document.getElementById("ddlImportance").value;
                    var PubFlag = document.getElementById("ddlPubFlag").value;    
                    var lsttype = getCellSelPlates();
                    MsQuery.content  = vtitle +"~"+content+"~"+userid+"~"+Level+"~"+PubFlag+"~"+lsttype+"~"+type;
                    var jsonExpr = JSON.stringify(MsQuery,function(key,value){return value;}); 
                      MsQuery = null;
                    PageMethods.DoSaveMes(jsonExpr,vtype,ClientCallBack); 
                }
                  function ClientCallBack(vResult)
                  {
                         eval("resultObj ="+vResult)
                            if(resultObj.result!="-999")
                            {
                                alert(resultObj.message);
                                switch(resultObj.ctype)
                                {
                                    case "1":
                                        document.getElementById("_hidsQueryId").value=resultObj.result;
                                        break;
                                    case "2":
                                        document.getElementById("_hidsQueryId").value="";
                                        document.getElementById("txtQueryName").value="";
                                        break;
                                }
                                document.getElementById('Query').style.display="none";
                                 var Type = document.getElementById("_hidTypeId").value; 
                                 var oPageParam="Type="+Type;
                                 var encodeParam=base64encode(oPageParam); 
                                 var Url = "notify_manage_querylist.aspx?" + encodeParam;
                                 parent.frames[0].document.location.href=Url;       
                            }
                            else
                            {
                                 alert(resultObj.message);
                                 return false;
                            }
                  }
                  function DoBack()
                  {
                    var pageSource = document.getElementById("_hidTypeId").value;
                    var url;
                    if (pageSource == "1")   //信息发布
                        {
                            url = "notify_manage_list.aspx";
                        }
                        if (pageSource == "2")   //信息查询
                        {
                            url = "notify_view_list.aspx" ;
                        }       
                     parent.document.location=url; 
                  }
                  function getCellSelPlates() {
                    var oOptions = document.getElementById("lstType").options;
                    var iLen = oOptions.length;
                    var oOption;            
                    var flowid=""; 
                    for(var i = 0; i < iLen; i ++) { 
                        oOption = oOptions[i];
                        if(oOption.selected == true)
                        { 
                                flowid +=(flowid=="")?oOption.value:","+oOption.value;  
                        }
            } 
           return  flowid;
        }
        function doSelect()
        {
                var typeid = document.getElementById("_hidTypeId").value;
                var vtitle = document.getElementById("txtTitle").value;
                var content = document.getElementById("txtContent").value;
                var userid = document.getElementById("_hidUserId").value;
                var Level = document.getElementById("ddlImportance").value;
                var PubFlag = document.getElementById("ddlPubFlag").value;    
                var Cls = getCellSelPlates();
                var timeday;
                
                var type;
                    var radiotype = document.getElementById("radiotype");
                    if(radiotype.checked==true)
                    {
                        type = 0;
                    }
                    var radioDay = document.getElementById("radioDay");
                    if(radioDay.checked==true)
                    {
                        type = 1;
                    }
                    var radioWeek = document.getElementById("radioWeek");
                    if(radioWeek.checked==true)
                    {
                        type = 2;
                    }
                    var radioMonth = document.getElementById("radioMonth");                      
                    if(radioMonth.checked==true)
                    {
                        type = 3;
                    }
                     var radiorange = document.getElementById("radiorange");
                     if(radiorange.checked==true)
                     {
                        if(document.getElementById("txtrange").value.Trim()!="")
                        {
                            type =4 ;
                            timeday = document.getElementById("txtrange").value;
                        }   
                        else
                        {
                            alert("之前的多少天没有填写")
                            return false;
                        }                     
                     }
                     var radioDesignated = document.getElementById("radioDesignated");
                     if(radioDesignated.checked==true)
                     {
                        var begintime = document.getElementById("txtBeginTime").value;
                        var Endtime = document.getElementById("txtEndTime").value;
                        if(begintime.Trim()!=""&&Endtime.Trim()!="")
                        {
                            if(!begintime.IsDate()&&!Endtime.IsDate())
                            {
                                alert("指定范围时间格式不正确!")
                                return false;
                            }
                            else
                            {
                               type =5;
                               timeday = begintime+"~"+Endtime;
                            }
                        }
                        else
                        {
                            alert("尚未填写指定范围时间!")
                            return false;
                        }
                     }
               var osb = new StringBuilder;
               osb.append("<Query><TitleName><![CDATA[").append(vtitle).append("]]></TitleName>");     
               osb.append("<Content><![CDATA[").append(content).append("]]></Content>");
               osb.append("<Creator><![CDATA[").append(userid).append("]]></Creator>");
               osb.append("<Level><![CDATA[").append(Level).append("]]></Level>");
               if(typeid=="1")
               {
                   osb.append("<PubFlag>").append(PubFlag).append("</PubFlag>");
                   osb.append("<ReadFlag><![CDATA[").append("").append("]]></ReadFlag>");   
               }
               else
               {
                   osb.append("<PubFlag>").append("").append("</PubFlag>");
                   osb.append("<ReadFlag><![CDATA[").append(PubFlag).append("]]></ReadFlag>");   
               }
               osb.append("<Class><![CDATA[").append(Cls).append("]]></Class>");
               osb.append("<Time Type='"+type+"'><![CDATA[").append(timeday).append("]]></Time>");               
               osb.append("</Query>");               
               return  osb.toString();
        }
         </script> 
         <style type="text/css">
      .skin
        {
            border-right: buttonhighlight 2px outset;
            border-top: buttonhighlight 2px outset;
            font-size: 9pt;
            visibility: hidden;
            border-left: buttonhighlight 2px outset;
            width: 100px;
            cursor: default;
            border-bottom: buttonhighlight 2px outset;
            font-family: Arial, Helvetica, sans-serif;
            position: absolute;
            background-color: menu;
            text-align: left;
        }
        .menuitems
        {
            padding-right: 5px;
            padding-left: 5px;
            padding-top: 5px;
            padding-bottom: 5px;
        }
    </style>
</head>
<body>
    <ccit:ActionForm id="form1" runat="server">
    <input type="hidden" id="_hidsQueryId" runat="server" />
    <input type="hidden" id="_hidTypeId" runat="server" />
    <input type="hidden" id="_hidUserId" runat="server" />
    <input type="hidden" id="_hidXml" runat="server" />
     <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
        </asp:ScriptManager>       
      <%--  <div id="Query" style="display: none; text-align: center; width: 250px; height: 90px;
        border: 1px #919B9C solid; position: absolute; top: 280px; left: 200px; background: #F8F8F5;">
        <div style="padding-top: 10px;">
            条件名称
            <input name="txtQueryName" type="text" id="txtQueryName" class="input" />
        </div> 
        <div style="padding-top: 20px;">
            <input name="btndivOk" type="button" id="btndivOk" class="button" value="确定" onclick="doSave()" />&nbsp;&nbsp;&nbsp;&nbsp;
            <input name="btndivCancle" type="button" id="btndivCancle" class="button" value="取消" onclick="document.getElementById('Query').style.display='none';" />
        </div>
     </div>--%>
     <table cellpadding="0" class="tableborder" cellspacing="0" width="98%" align="center" id="tdMessage" runat="server">
            <tr>
			  <td  width="15%" height="14" align="right" class="pformleft"><nobr>标题包含</nobr>			  </td>
				<td  align="left" class="pformright" colspan="3">
				    <asp:TextBox  ID="txtTitle" Runat="server" CssClass="input" Width="98%"></asp:TextBox>			  				    
				</td>
			</tr> 
			<tr>
			  <td  width="15%" height="14" align="right" class="pformleft"><nobr>内容包含</nobr>			  </td>
				<td  align="left" class="pformright" colspan="3">
				    <asp:TextBox  ID="txtContent" Runat="server" CssClass="input" Width="98%"></asp:TextBox>			  				    </td>
			</tr> 
			<tr>
			  <td  width="15%" height="14" align="right" class="pformleft"><nobr>发布人</nobr>			  </td>
				<td  align="left" class="pformright" colspan="3">
				<nobr>
				    <asp:TextBox  ID="txtUserName" Runat="server" CssClass="input" Width="95%" ReadOnly></asp:TextBox>
				    <a href="javascript:OpenDept('_hidUserId','txtUserName')" class="linktext"><IMG  id="IMG3" title="选择人员" src="../images/select.gif" relaobj="txtUserName"></a>
				</nobr>
				</td>
			</tr> 
		 <tr>
			  <td  width="15%" height="14" align="right" class="pformleft"><nobr>重要程度</nobr>
			  </td>
			  <td  align="left" class="pformrightline" >
				  <asp:DropDownList  ID="ddlImportance" Runat="server" CssClass="input" Width="90%"></asp:DropDownList>			  				    </td>
		      <td  height="14" align="right" class="pformleft"><nobr><asp:Label ID="lblstate" runat="server">&nbsp;</asp:Label></nobr></td>
				<td  align="left" class="pformright" >
				    <asp:DropDownList  ID="ddlPubFlag" Runat="server" CssClass="input" Width="90%"></asp:DropDownList>	
				 </td>
	   </tr> 
	    <tr>
	        <td width="10%" align="center" class="pformleft">&nbsp;</td>
            <td align="center" class="pformrightline" width="30%"><strong>通知类型</strong></td> 
            <td width="5%" align="center" class="pformleft">&nbsp;</td>
            <td width="30%" align="center" class="pformleft"><strong>时间范围</strong></td>
       </tr>
       <tr>    <td width="10%" align="center" class="pformleft">&nbsp;</td>   
        <td valign="top" class="pformrightline"><asp:ListBox ID="lstType" 
                Width="98%"  Rows="8" SelectionMode="Multiple" 
		                               runat="server" Height="149px"></asp:ListBox></td> 
		     <td width="10%" align="center" class="pformleft">&nbsp;</td>
        <td valign="top" class="pformright">
            <table  cellpadding="0" class="tableborder" cellspacing="0" width="98%" align="center" runat="server">
                <tr>
                    <td valign="top" class="pformrightline">
                        <asp:RadioButton Text="全部时间范围" ID="radiotype" runat="server" GroupName="radioButtonList" Checked="true"/>
                    </td>
                </tr>
                <tr>
                    <td valign="top" class="pformrightline">
                    <nobr>
                        <asp:RadioButton Text="当天" ID="radioDay" runat="server" GroupName="radioButtonList"/>
                        <asp:RadioButton Text="当周" ID="radioWeek" runat="server" GroupName="radioButtonList" />
                        <asp:RadioButton Text="当月" ID="radioMonth" runat="server" GroupName="radioButtonList" /> 
                    </nobr>
                    </td>
                </tr>
                <tr>
                    <td valign="top" class="pformrightline">
                       <nobr>
                            <asp:RadioButton Text="之前" ID="radiorange" runat="server" GroupName="radioButtonList" />
                            <asp:TextBox ID="txtrange" CssClass="input" Width="40" runat="server"></asp:TextBox>
                            天以内
                       </nobr>
                    </td>
                </tr>
                <tr>
                    <td valign="top" class="pformrightline">
                         <asp:RadioButton Text="指定时间范围" ID="radioDesignated" runat="server" GroupName="radioButtonList" />
                    </td>
                </tr>
                <tr>
                    <td valign="top" class="pformrightline">
                         <nobr>
                         <nobr>
                            从<asp:TextBox ID="txtBegInTime" CssClass="input" Width="120" runat="server"></asp:TextBox>
                             <img class="getdate" src="../images/toolbar/Calendar.gif"  relaobj="txtBegInTime"/>
                         </nobr>
                         </nobr>
                    </td>
                </tr>
                <tr>
                    <td valign="top" class="pformrightline">
                    <nobr>
                        至<asp:TextBox ID="txtEndTime" CssClass="input" Width="120" runat="server"></asp:TextBox>
                         <img class="getdate" src="../images/toolbar/Calendar.gif"  relaobj="txtEndTime"/>
                    </nobr>
                    </td>
                </tr>
            </table>
        </td>
       </tr>
       <tr class="pformstrip" height="20">
               <td colspan="4" align="center">
                   <asp:Button ID="btnSearch" runat="server" Text="执行查询" CssClass="button" 
                       onclick="btnSearch_Click" />
                    &nbsp;
                    <input type="button" id="btnSaveCont" value="保存条件" class="button" onclick="OpenQuery('1')" />
                    &nbsp;
                    <input type="button" id="btnSaveBack" value="保存" class="button" onclick="OpenQuery('2')" />
                    &nbsp;  
                    <input type="button" id="btnBack" value="取消" class="button" onclick="DoBack()" />
                    &nbsp;
                </td>
            </tr>
      </table>
      
    <div id="Query"  style="display: none; text-align: center; width: 200px; height: 50px;
        border: 1px #919B9C solid; position: absolute; top: 340px; left: 100px; ">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <table width="300" border="1" cellpadding="0" cellspacing="0" bordercolor="#ECE9D8" class="tableborder"
                         >
                        <tbody>
                            <tr>
                                <td height="35">
                                    <table width="70%" border="0" align="center" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td> 
                                                    <nobr>
                                                    条件名称：
                                                    <input type="text" id="txtQueryName" class="input" width="60" runat="server" />
                                                    </nobr> 
                                            </td>
                                        </tr>
                                        <tr>
                                        <td align="center">
                                            <nor>
                                                <input type="button" id="Button1" value="确定" onclick="doSave();" />
                                                &nbsp;
                                                <input type="button" id="btnClose"  onclick="document.getElementById('Query').style.display='none';"value="取消" />
                                            </nor></td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </tbody>                    
                    </table>
                   </ContentTemplate>
                </asp:UpdatePanel>
          </div>
      
    </ccit:ActionForm>
</body>
</html>
